package chapter03

/**
 * @program lu-scala01
 * @description: 动态绑定
 * @author: zhanglu
 * @create: 2022-03-12 14:52:00
 */
object C08_DynamicBind {

  def main(args: Array[String]): Unit = {
    val worker: Worker08 = new Worker08
    println(worker.name)
    worker.hello

    println("=======")

    val person: Person08 = new Worker08
    println(person.name)
    person.hello
  }

}

class Person08{
  val name: String = "Person"
  def hello: Unit ={
    println("hello person")
  }
}

class Worker08 extends Person08{
  override val name: String = "Worker"
  override def hello: Unit = {
    println("hello worker")
  }
}